package protocol.SZ_2021;

import java.util.HashMap;

public class Handle2021SZ0A implements IHandle2021SZ {
    @Override
    public String handle(SZ_2021Cmd cmd) {
        byte subOrder = cmd.subOrder();

        switch (subOrder){
            case 0x12:
                return handle0A12(cmd);
            default:
                return "深标:未匹配的命令字"+(cmd.readOrder()+","+cmd.readSubOrder());
        }
    }

    private String handle0A12(SZ_2021Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:终端响应照片查询指令");
        builder.append("\r\n");

        HashMap<Integer,String> list = new HashMap<>();
        list.put(0,"司机电子证件照");
        list.put(1,"人脸识别");
        list.put(2,"其他");
        builder.append("下载用途:"+list.getOrDefault(cmd.readInt(1),"未定义"));
        builder.append("\r\n");

        int num = cmd.readInt();
        builder.append("照片数量:"+num);
        builder.append("\r\n");
        for (int i = 0; i < num; i++) {
            builder.append("    照片ID:"+cmd.readInt(4));
            builder.append("\r\n");
        }

        return builder.toString();
    }
}
